package com.xujie.sportsmeeting.vo;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.math.BigDecimal;

/**
 * 排行榜VO
 */
@Data
@Schema(description = "排行榜信息")
public class RankingVO {

    @Schema(description = "排名")
    private Integer ranking;

    @Schema(description = "排名变化")
    private Integer rankingChange;

    @Schema(description = "名称(运动员姓名或团体名称)")
    private String name;

    @Schema(description = "类型")
    private String type; // athlete, department, class

    @Schema(description = "院系")
    private String department;

    @Schema(description = "班级")
    private String className;

    @Schema(description = "总得分")
    private BigDecimal totalScore;

    @Schema(description = "金牌数")
    private Integer goldMedals;

    @Schema(description = "银牌数")
    private Integer silverMedals;

    @Schema(description = "铜牌数")
    private Integer bronzeMedals;

    @Schema(description = "总奖牌数")
    private Integer totalMedals;

    @Schema(description = "参赛项目数")
    private Integer participatedEvents;

    @Schema(description = "头像或图标")
    private String avatar;

    // 获取排名变化描述
    public String getRankingChangeText() {
        if (rankingChange == null || rankingChange == 0) return "—";
        if (rankingChange > 0) return "↑" + rankingChange;
        return "↓" + Math.abs(rankingChange);
    }

    // 获取总奖牌数
    public Integer getTotalMedals() {
        int total = 0;
        if (goldMedals != null) total += goldMedals;
        if (silverMedals != null) total += silverMedals;
        if (bronzeMedals != null) total += bronzeMedals;
        return total;
    }
}
